#include<bits/stdc++.h>
using namespace std;
struct ii{
    int e,f;
};
struct pp1{
    int a,b,c;
}pp[1001];
vector<ii>ans;
double cc(pp1 l,int s)
{
	return sqrt(l.a*l.a+2*l.b*(s-l.c));
}
double ca(pp1 s)
{
    return s.a*(3-s.b)/s.a+(3-s.b)*(3-s.a)/2*s.b+s.c;
}
inline void solve()
{
    int n,m,v,l,p,d[10001];
    int minn=0x3f,maxn=-0x3f;
    cin>>n>>m>>l>>v;
    for(int i=1;i<=n;i++)
    {
        cin>>pp[i].a>>pp[i].b>>pp[i].c;
        if(pp[i].b<0) p=1;
        if(pp[i].b=0) p=0;
        if(pp[i].b>0) p=-1;
    }
    for(int i=1;i<=m;i++)
    {
        cin>>d[i];
    }
    int sum=0;
    vector<int>o;
    if(p==0)
    {
        int minn=0x3f,k=1;
        for(int i=1;i<=n;i++)
        {
            if(pp[i].a>v)
            {
                sum++;
                o.push_back(i);
            }
        }
        cout<<sum<<" ";
        for(int j=0;j<o.size();j++)
            minn=min(minn,pp[0].c);

        sort(d+1,d+1+m);
        while(d[k]<minn) k++;
        cout<<k<<endl;

    }
    if(p==1)
    {
		for(int i=1;i<=n;i++)
		{
			if(cc(pp[i],d[1])>v)
			{
				sum++;
				o.push_back(i);
			}
	    }
        int maxn=-0x3f;
        for(int i=0;i<o.size();i++)
            maxn=max(double(maxn),ca(pp[i]));
        int k=m;
        while(d[k]>maxn) k--;
        cout<<m-k<<endl;
    }
    if(p==-1)
    {
		for(int i=1;i<=n;i++)
		{
			if(cc(pp[i],d[m])>v)
			{
				sum++;
				o.push_back(i);
			}
	    }
        int minn=0x3f;
        for(int i=0;i<o.size();i++)
            minn=min(double(minn),ca(pp[i]));
        int k=1;
        while(d[k]<minn) k++;
        cout<<k<<endl;
    }

}
int main()
{
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    for(int i=1;i<=t;i++)
        solve();
    return 0;
}
